import java.util.HashMap;
import java.util.Map;

public class Solution {
    public static int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {
        Map<Integer,Integer> map1 = new HashMap<>();

        int ret = 0;
        for (int i : nums1) {
            for (int j : nums2) {
                int sum = i + j;
                map1.put(sum,map1.getOrDefault(sum, 0) + 1);
            }
        }
        for (int i : nums3) {
            for (int j : nums4) {

                ret += map1.getOrDefault(0 - i - j,0);
            }
        }
        return ret;
    }

    public static void main(String[] args) {
           int[] nums1 = {1,2};
           int[] nums2={-1,-2};
           int[] nums3 = {-1,2};
           int[] nums4 = {0,2};
           int ret = fourSumCount(nums1,nums2,nums3,nums4);
        System.out.println(ret);
    }
}
